var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');

var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');

// 后台文章路由
var articleRouter = require('./routes/admin/article')
var categoryRouter = require('./routes/admin/category')
var settingRouter = require('./routes/admin/setting')

var app = express();

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', indexRouter);
app.use('/users', usersRouter);
// 后台路由配置
app.use('/admin/article', articleRouter)
app.use('/admin/category', categoryRouter)
app.use('/admin/setting', settingRouter)

module.exports = app;
